class Identity < ActiveRecord::Base
  belongs_to :site
  belongs_to :user
  
  def specific_page
    gsub_with_name(self.site.url_pattern || self.site.home_page)
  end
  
  def specific_image
    gsub_with_name(self.site.image)
  end
  
  def rss
    gsub_with_name(self.site.rss)
  end
  
  private
  def gsub_with_name(src)
    src.gsub "$", self.name if src
  end
end
